package com.lmx.repoDomain.tmodel;

import io.katharsis.resource.annotations.JsonApiIncludeByDefault;
import io.katharsis.resource.annotations.JsonApiResource;
import io.katharsis.resource.annotations.JsonApiToMany;
import io.katharsis.resource.annotations.JsonApiToOne;

import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.ForeignKey;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cache;
import org.hibernate.annotations.CacheConcurrencyStrategy;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

import com.lmx.repoDomain.tmodel.business.User;

/**
 * 护理等级表
 */
@JsonApiResource(type = "nursinglevel")
@Table(name = "tnb_nursinglevel")
@Entity
@Cache(usage = CacheConcurrencyStrategy.NONSTRICT_READ_WRITE)
public class NursingLevel extends BaseEntity {

	private User lastUpdateUser;// 更新操作者userid

	private Integer createDateTime;// 创建时间

	private User createUser;

	private Integer lastUpdateDateTime;// 更新时间

	private String remark;// 备注

	private String name;

	private String price;// 价格

	private List<NursingLevelServiceItem> services;// 所对应照护项目

	private List<Dicttype> selfCareLevel;// 自理能力等级

	private Integer lowScore;// 所对应最低分

	private Integer highScore;// 所对应最高分

	@Column(name = "price")
	public String getPrice() {
		return price;
	}

	public void setPrice(String price) {
		this.price = price;
	}

	@JsonApiToMany
	@OneToMany(fetch = FetchType.EAGER, cascade = CascadeType.REFRESH, mappedBy = "level")
	public List<NursingLevelServiceItem> getServices() {
		return services;
	}

	public void setServices(List<NursingLevelServiceItem> services) {
		this.services = services;
	}

	// @JsonApiToOne
	// @JsonApiIncludeByDefault
	// @ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	// @Fetch(FetchMode.JOIN)
	// @JoinColumn(name = "selfcarelevel_id", nullable = true, foreignKey =
	// @ForeignKey(name = "null"))
	@JsonApiToMany
	@JsonApiIncludeByDefault
	@ManyToMany(cascade = CascadeType.REFRESH, fetch = FetchType.LAZY)
	@JoinTable(name = "tnb_nursinglevel_carelevel", joinColumns = { @JoinColumn(name = "nursinglevel_id", nullable = false, updatable = false, foreignKey = @ForeignKey(name = "null")) }, inverseJoinColumns = { @JoinColumn(name = "carelevel_id", nullable = false, updatable = false, foreignKey = @ForeignKey(name = "null")) })
	@Fetch(FetchMode.JOIN)
	public List<Dicttype> getSelfCareLevel() {
		return selfCareLevel;
	}

	public void setSelfCareLevel(List<Dicttype> selfCareLevel) {
		this.selfCareLevel = selfCareLevel;
	}

	@Column(name = "lowscore")
	public Integer getLowScore() {
		return lowScore;
	}

	public void setLowScore(Integer lowScore) {
		this.lowScore = lowScore;
	}

	@Column(name = "highscore")
	public Integer getHighScore() {
		return highScore;
	}

	public void setHighScore(Integer highScore) {
		this.highScore = highScore;
	}

	@Column(name = "createDateTime")
	public Integer getCreateDateTime() {
		return createDateTime;
	}

	public void setCreateDateTime(Integer createDateTime) {
		this.createDateTime = createDateTime;
	}

	@Column(name = "lastUpdateDateTime")
	public Integer getLastUpdateDateTime() {
		return lastUpdateDateTime;
	}

	public void setLastUpdateDateTime(Integer lastUpdateDateTime) {
		this.lastUpdateDateTime = lastUpdateDateTime;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "createuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getCreateUser() {
		return createUser;
	}

	public void setCreateUser(User createUser) {
		this.createUser = createUser;
	}

	@JsonApiToOne
	@ManyToOne(fetch = FetchType.LAZY, cascade = CascadeType.REFRESH)
	@JoinColumn(name = "lastupdateuser_id", foreignKey = @ForeignKey(name = "null"))
	public User getLastUpdateUser() {
		return lastUpdateUser;
	}

	public void setLastUpdateUser(User lastUpdateUser) {
		this.lastUpdateUser = lastUpdateUser;
	}

	@Column(name = "name")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public NursingLevel() {
	}

	@Column(name = "remark")
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

}
